using System.Collections;

namespace CSharpPro._1014;

public class Demo
{
    public void TestPrint()
    {
        int[] arr = new int[5];
        for (int i = 0; i < 5; i++)
        {
            arr[i] = i;
        }
        int[] arr2 = new int[]{1,3,2,4,5};
        int[] arr3 = new int[5]{1,2,3,4,5};
        Console.WriteLine(arr2[0]);
        int[] arr4 = {1,2,3,4,5};
        //类似矩阵
        String[,] arr5 = new String[2,3];
        Console.WriteLine(arr5[0, 0]);
        //Sort升序 Reverse反转
        Array.Sort(arr2);
        foreach (var i in arr2)
        {
            Console.WriteLine(i+"\t");
        }

        ArrayList list = new ArrayList();
        list.Add(1);
        list.Add(2);
        list.Add(3);
        Console.WriteLine(list.Contains(2));
        Console.WriteLine(list.Contains(5));

        Hashtable hashtable = new Hashtable();
        hashtable.Add("1",1);
        hashtable.Add("2","222");
        hashtable.Add("3",list);
        Console.WriteLine(hashtable.GetType());
        
    }
    
    
    //作业1：冒泡排序
    public void TestPrint2()
    {
        int[] arr ={1,2,3,4,5};
        for (int i = 0; i < arr.Length - 1; i++)
        {
            for (int j = 0; j < arr.Length - 1 - i; j++)
            {
                if (arr[j] < arr[j + 1])
                {
                    int temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;
                }
            }
        }
        //降序
        for (int i = 0; i < arr.Length; i++)
        {
            Console.WriteLine(arr[i]);
        }

        
    }
}